{extend name="main" /}

{block name="body"}
{include file="breadcrumb" /}
<div class="layui-fluid">
    <table class="layui-table" style="margin-top: 0;">
        <tr>
            <th><b>ID</b></th>
            <th><b>标题</b></th>
            <th><b>内容</b></th>
            <th><b>类型</b></th>
            <th><b>发送时间</b></th>
            <th style="padding: 0 15px;line-height: 40px;"><b>操作</b> <span style="float: right"><a href="{:url('add')}" data-width="1000px" data-height="650px" class="layui-btn layui-btn-sm xn_open" title="添加消息">添加消息</a></span> </th>
        </tr>

        <tbody>
        {foreach name="list" item="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.title}</td>
            <td>{$vo.content}</td>
            <td>系统消息</td>
            <td>{:date('Y-m-d H:i:s',$vo.create_time)}</td>
            <td>
                <a href="{:Url('delete',array('id'=>$vo['id']))}" title="确认要删除【{$vo.title}】吗？" class="layui-btn layui-btn-danger layui-btn-xs xn_delete">
                    <i class="layui-icon layui-icon-delete"></i>删除
                </a>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
</div>
{/block}

{block name="js"}
<script>
    layui.form.on('switch(is_sh)', function(data){
        //layer.tips('开关checked：'+ (this.checked ? 'true' : 'false'), data.othis)
        var val = this.checked ? 1 : 0;
        var id = $(this).attr('data-id');
        var url = "{:url('edit')}";
        $.post(url,{id:id,is_sh:val},function (res) {
            console.log(res);
            layer.tips(res.msg, data.othis);
        },'json')
    });
    layui.form.on('switch(is_tui)', function(data){
        //layer.tips('开关checked：'+ (this.checked ? 'true' : 'false'), data.othis)
        var val = this.checked ? 1 : 0;
        var id = $(this).attr('data-id');
        var url = "{:url('edit')}";
        $.post(url,{id:id,is_tui:val},function (res) {
            console.log(res);
            layer.tips(res.msg, data.othis);
        },'json')
    });
</script>
{/block}